//package com.seadragon.apps.doctorcard.controller;
//
//import java.util.HashSet;
//import java.util.Random;
//import java.util.Set;
//
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.messaging.handler.annotation.DestinationVariable;
//import org.springframework.messaging.handler.annotation.MessageMapping;
//import org.springframework.messaging.simp.SimpMessagingTemplate;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Controller;
//
//@Controller
//public class WebsocketController {
//	private static Logger logger = LoggerFactory.getLogger(WebsocketController.class);
//	private SimpMessagingTemplate messagingTemplate;
//	private Set<Long> subscriberIds=new HashSet<>();
//	
//	@Autowired
//	public WebsocketController(SimpMessagingTemplate smt){
//		this.messagingTemplate = smt;
//	}
//	
//	@MessageMapping("/updateNumber/{sid}")
//	public void subscribForUnreadNumberOfReqeust(@DestinationVariable Long sid) {
//		logger.info("subscribe update-unread-number from id="+sid);
//		if (!this.subscriberIds.add(sid)){
//			logger.warn("this service is already subscribed for subscriber with id="+sid);
//		};
//	}
//	
//	
//	@MessageMapping("/unsubscribeUpdateNumber/{sid}")
//	public void unsubscribForUnreadNumberOfReqeust(@DestinationVariable Long sid) {
//		logger.info("unsubscribe update-unread-number from id="+sid);
//		if (!this.subscriberIds.remove(sid)){
//			logger.warn("this service is already unsubscribed for userid="+sid);
//		};
//	}
//	
//	@Scheduled(fixedDelay=2000)
//	public void sendNumber() {
//		for (Long id : this.subscriberIds) {
//			this.messagingTemplate.convertAndSend("/queue/updatedNumber-" +id, new Random().nextInt(10));
//		}
//	}
//	
//	
//}
